package leetcode.code0083;

import leetcode.helper.tree.ListNode;

public class Solution extends Solution83 {

	@Override
	public ListNode deleteDuplicates(ListNode head) {
		if (head == null)
			return head;
		ListNode p1 = head.next;
		ListNode p2 = head;
		while (p1 != null) {
			if (p1.val != p2.val) {
				p2.next = p1;
				p2 = p1;
			}
			p1 = p1.next;
		}
		p2.next = null;// 多余的尾巴一刀斩 [1,1,2,3,3]
		return head;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
	}

}
